package com.oa.ylms.apps.dao.move.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.oa.ylms.apps.dao.move.IPersonMoveCheckDao;
import com.oa.ylms.apps.entity.move.PersonMoveCheckValue;

public class PersonMoveCheckDaoImpl extends HibernateDaoSupport implements
		IPersonMoveCheckDao {

	@Override
	public int addPersonMoveCheck(PersonMoveCheckValue personMoveCheck)
			throws Exception {
		if(personMoveCheck != null){
			this.getHibernateTemplate().save(personMoveCheck);
			return personMoveCheck.getCheckId();
		}
		return 0;
	}

	@Override
	public PersonMoveCheckValue queryByCheckId(
			PersonMoveCheckValue personMoveCheck) throws Exception {
		if(personMoveCheck != null){
			return (PersonMoveCheckValue) this.getHibernateTemplate().get(PersonMoveCheckValue.class, personMoveCheck.getCheckId());
		}
		return null;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PersonMoveCheckValue> queryPersonMoveCheck(PersonMoveCheckValue personMoveCheck) throws Exception {
		if(personMoveCheck != null){
			String hql = "FROM PersonMoveCheckValue pmcv WHERE pmcv.personMoveInfo = ?";
			return this.getHibernateTemplate().find(hql,personMoveCheck.getPersonMoveInfo());
		}
		return null;
	}

}
